#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;

const int kMaxN = 1e4 + 10;
const int kMaxC = 31;

double f[kMaxN][kMaxC];
int X[kMaxN], Y[kMaxN];

double Dist(int i, int j) {
  return sqrt((X[i] - X[j]) * (X[i] - X[j]) + (Y[i] - Y[j]) * (Y[i] - Y[j]));
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> X[i] >> Y[i];
  }
  for (int i = 0; i < n; i++) {
    fill(f[i], f[i] + kMaxC, 1e9);
  }

  f[0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < kMaxC; j++) {
      for (int k = 0; i + k + 1 < n && j + k < kMaxC; k++) {
        f[i + k + 1][j + k] = min(f[i + k + 1][j + k], f[i][j] + Dist(i, i + k + 1));
      }
    }
  }
  double ans = f[n - 1][0];
  for (int j = 1; j < kMaxC; j++) {
    ans = min(f[n - 1][j] + (1 << j - 1), ans);
  }
  cout << fixed << setprecision(10) << ans << "\n";
  return 0;
}